package service

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Success(ctx *gin.Context, v interface{}) {
	ctx.JSON(http.StatusOK, map[string]interface{}{
		"code": 200,
		"msg":  "SUCCESS",
		"data": v,
	})
}
func Error(ctx *gin.Context, msg string, v interface{}) {
	ctx.JSON(http.StatusOK, map[string]interface{}{
		"code": -1,
		"msg":  msg,
		"data": v,
	})
}
func PanicError(ctx *gin.Context, msg string, err error) {
	if err != nil {
		ctx.JSON(http.StatusOK, map[string]interface{}{
			"code": -1,
			"msg":  msg,
			"data": err.Error(),
		})
		return
	}
}
